package ModelLag;



import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class PersonContainerTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class PersonContainerTest
{
    private PersonContainer pCon;
    private Person p1,p2,p3;
    
    /**
     * Default constructor for test class PersonContainerTest
     */
    public PersonContainerTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
    }
    
    @Test
    public void testIfPersonAdded(){
        p1 = new Person("Patrick", "Grævlingevej 17", "7000", "Aabenraa", "70707070");
        pCon = PersonContainer.getInstance();
        pCon.addPerson(p1);
        
        assertSame(p1, pCon.getPerson("70707070"));
    }
    
    @Test
    public void testIfMultiplePersonsAdded(){
        p1 = new Person("Patrick", "Grævlingevej 17", "7000", "Aabenraa", "70707070");
        p2 = new Person("Anders", "Sigridsvej 17", "8000", "Aarhus", "80808080");
        p3 = new Person("Nick", "Daulumvej 17", "9000", "Aalborg", "90909090");
        pCon = PersonContainer.getInstance();
        
        pCon.addPerson(p1);
        pCon.addPerson(p2);
        pCon.addPerson(p3);
        
        assertSame(p2, pCon.getPerson("80808080"));
    }
    
    @Test
    public void testIfNoPersonAdded(){
        pCon = PersonContainer.getInstance();
        
        assertSame(null, pCon.getPerson("80808080"));
    }
    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    
    @After
    public void tearDown()
    {  
        pCon.deletePerson(p1);
        pCon.deletePerson(p2);
        pCon.deletePerson(p3); 
    }
    
}
